JavaScript

A5.u.colorstringify Method

Syntax

A5.u.color.stringify(color[,format])

Arguments

colorobject

The color to stringify.

formatstring

The format to return the color in. A value of "#" (the default) will return the color in hex format. Value of "hsl", "hsla", "rgb" and "rgba" will return the color in those standard formats. A value of "hsl*" or "rgb*" will return the "alpha" component only if it is not equal to "1".

Returns

colorstring

The color in the specified format.

Description

Convert the values in a color object into the specified format.

Discussion

This method will take a color object (such as the one returned from A5.u.color.prase) and return a color string.

Example

var c = A5.u.color.parse('rgb(100,50,0)');
// c = {"h":30,"s":100,"l":19.61,"r":100,"g":50,"b":0,"a":1}
var c1 = A5.u.color.stringify(c);
// c1 = "#643200"
var c2 = A5.u.color.stringify(c,'hsl*');
// c2 = "hsl(30,19.61,100)"
c.a = .75;
var c2 = A5.u.color.stringify(c,'hsl*');
// c3 = "hsla(30,19.61,100,0.75)"